$(function(){
	var url={
		list:'{:url("adminapi/car_scrap/scrapList")}',//列表
		delete:'{:url("adminapi/car_scrap/delete")}',//删除
		//http://127.0.0.1/adminapi/Car_Scrap/delete?car_scrap_id=1
		check:'{:url("adminapi/car_scrap/checkScrap")}',//审核
		//http://127.0.0.1/adminapi/Car_Scrap/checkScrap?car_scrap_id=4&state=2
		//http://127.0.0.1/adminapi/Car_Scrap/checkScrap?car_scrap_id=4&state=4
		//http://127.0.0.1/adminapi/Car_Scrap/checkScrap?car_scrap_id=4&state=6
		//http://127.0.0.1/adminapi/Car_Scrap/checkScrap?car_scrap_id=4&state=7
        //http://127.0.0.1/adminapi/Car_Scrap/checkScrap?car_scrap_id=4&state=8
        //http://127.0.0.1/adminapi/Car_Scrap/checkScrap?car_scrap_id=4&state=9
        add:'{:url("adminapi/car_scrap/add")}',//增加
		//http://127.0.0.1/adminapi/Car_Scrap/add?car_id=233&why=123213123
		upload:'{:url("adminapi/Upload/uploadImg")}'
	}
	$('.scrap').on('click',function(){
		propcheck($(this))
	})
	var page=1;
	var tddata=[
		{
			key:'car_scrap_id',
			type:1,
			url:''
		},{
			key:'number',
			type:2,
			url:'{:url("detail")}',
			id:137
		},{
			key:'brand',
			type:1,
			url:''
		},{
			key:'car_type_name',
			type:1,
			url:''
		},{
			key:'company_name',
			type:1,
			url:''
		},{
			key:'time',
			type:1,
			url:''
		},{
			key:'state2',
			type:1,
			url:''
		}];
	var addoperation=`<td>
						<div class="tpl-table-black-operation operate">
							<a href="javascript:;" class="tpl-table-black-operation-del scrap_close" data-method="delete">
								<i class="am-icon-pencil"></i> 删除
							</a>
						</div>
					</td>`
	var data={};
	data.page=page;
	data.pagenum=10;
	var where_json={};
	{if $Think.get.car_scrap_id}
		where_json.car_scrap_id=['like',"%{$Think.get.car_scrap_id}%"];
	{/if}
	{if $Think.get.company_name}
		where_json.company_name=['like',"%{$Think.get.company_name}%"];
	{/if}
	{if $Think.get.number}
		where_json.number=['like',"%{$Think.get.number}%"];
	{/if}
	{if $Think.get.state}
		where_json.state=['in',"{$Think.get.state}"];
	{/if}
	
	data.where_json=JSON.stringify(where_json)
	ajaxscrap(data)
	function ajaxscrap(data){
		Load()
		$.ajax({
			type:"post",
			url:url.list,
			data:data,
			success:function(res){
				Load(1)
				console.log(res)
				
				for(var stateidx=0;stateidx<res.data.length;stateidx++){
					if(res.data[stateidx].state==1){
						res.data[stateidx].state2='待评估'
					}else if(res.data[stateidx].state==2){
						res.data[stateidx].state2='待审核'
					}else if(res.data[stateidx].state==3){
						res.data[stateidx].state2='评估不通过'
					}else if(res.data[stateidx].state==4){
						res.data[stateidx].state2='已审核'
					}else if(res.data[stateidx].state==5){
						res.data[stateidx].state2='审核不通过'
					}else if(res.data[stateidx].state==6){
						res.data[stateidx].state2='已确认'
					}else if(res.data[stateidx].state==7){
						res.data[stateidx].state2='已登记'
					}else if(res.data[stateidx].state==8){
						res.data[stateidx].state2='已复审'
					}else if(res.data[stateidx].state==9){
						res.data[stateidx].state2='完成'
					}
				}
				
				$('tbody').html(tbodymainf2(res.data, 1, tddata, addoperation, 'car_scrap_id'))
				$('.pagination').html(pagechang1(res.count, 10, page))
			
				
					$('tbody tr').each(function(){
					var operate='';
					for(var idx=0;idx<res.data.length;idx++){
						if(res.data[idx].car_scrap_id==$(this).data('id')){
							if(res.data[idx].state==1){
								operate=`<a class='assess'>
										<i class="am-icon-pencil"></i> 评估
									</a>`
								
							}else if(res.data[idx].state==2){
								operate=`<a class='first_check'>
										<i class="am-icon-pencil"></i>审核
									</a>`
							}else if(res.data[idx].state==4){
								operate=`<a class='notarize'>
										<i class="am-icon-pencil"></i> 确认
									</a>
									<a class='detail' data-type='3'>
										<i class="am-icon-pencil"></i> 详情
									</a>`
							}else if(res.data[idx].state==6){
								operate=`<a class='second_check'>
										<i class="am-icon-pencil"></i> 登记
									</a>
									<a class='detail' data-type='4'>
										<i class="am-icon-pencil"></i> 详情
									</a>`
							}else if(res.data[idx].state==7){
								operate=`
									<a class='second_notarize'>
										<i class="am-icon-pencil"></i> 复审
									</a>
									<a class='detail' data-type='5'>
										<i class="am-icon-pencil"></i> 详情
									</a>`
							}else if(res.data[idx].state>=8){
								operate=`
								
									<a class='detail' data-type='6'>
										<i class="am-icon-pencil"></i> 详情
									</a>`
							
								
							}
						}
					}
					$(this).find('.operate').append(operate)
				})
				
				$('.laquo').on('click',function(){
					page-=1;
					data.page=page
					console.log(page)
					ajaxscrap(data)
				})
				$('.pageli').on('click',function(){
					page=$(this).html()
					data.page=page
					ajaxscrap(data)
				})
				//下一页
				$('.raquo').on('click',function(){
					page+=1;
					data.page=page
					ajaxscrap(data)
				});
				
				$('.scrap_close').on('click',function(){
					var main={};
					for(var i=0;i<res.data.length;i++){
						if(res.data[i].car_scrap_id==$(this).closest('tr').data('id')){
							main=res.data[i]
						}
					}
					scrapclose($(this),main)
				})
				$('.assess').on('click',function(){
					var main={};
					for(var i=0;i<res.data.length;i++){
						if(res.data[i].car_scrap_id==$(this).closest('tr').data('id')){
							main=res.data[i]
						}
					}
					assess($(this),main)
				})
				$('.first_check').on('click',function(){
					var main={};
					for(var i=0;i<res.data.length;i++){
						if(res.data[i].car_scrap_id==$(this).closest('tr').data('id')){
							main=res.data[i]
						}
					}
					firstcheck($(this),main)
				})
				$('.notarize').on('click',function(){
					var main={};
					for(var i=0;i<res.data.length;i++){
						if(res.data[i].car_scrap_id==$(this).closest('tr').data('id')){
							main=res.data[i]
						}
					}
					notarize($(this),main)
				})
				$('.second_check').on('click',function(){
					var main={};
					for(var i=0;i<res.data.length;i++){
						if(res.data[i].car_scrap_id==$(this).closest('tr').data('id')){
							main=res.data[i]
						}
					}
					secondcheck($(this),main)
				})
				$('.second_notarize').on('click',function(){
					var main={};
					for(var i=0;i<res.data.length;i++){
						if(res.data[i].car_scrap_id==$(this).closest('tr').data('id')){
							main=res.data[i]
						}
					}
					secondnotarize($(this),main)
				})
				$('.detail').on('click',function(){
					var main={};
					for(var i=0;i<res.data.length;i++){
						if(res.data[i].car_scrap_id==$(this).closest('tr').data('id')){
							main=res.data[i]
						}
					}
					detailscrap($(this),main)
				})
			}
		});
	}
	function propcheck(obj){
		var auto = layer.open({
   		type: 1,
   		title:'车辆报废申请',
   		skin: 'layui-layer-rim', //加上边框
   		area: ['600px', '400px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
   			<form class="am-form-inline tpl-form-border-form" enctype="multipart/form-data" data-check="1" data-ajax="1" id="scrap3">
	   			<div class='am-u-sm-12'>
	   				<div class="am-u-sm-12" style='margin-bottom:10px'>
		   				<div class='am-fl' style="padding:0 10px">
		   					<input type="hidden" class="CarId" name="car_id" value="{$item.car_id}" />
							<input type="text" class="am-form-field tpl-form-no-bg  car_number" value="{$item.car_number}" name="car_number" data-check='require' data-msg="车牌号不能为空" readonly="" />
		   				</div>
		   				<div class='am-btn-group am-fl am-btn-group-xs cl-p' >
		   					<button type="button" class='am-btn am-btn-default car_detail'>查看车辆详情</button>
		   				</div>
	   			
	   				</div>
	   				<div class="am-u-sm-12">
		   				<div class='am-u-sm-12'>
			   				<textarea class='why' style='height:150px' placeholder='请填写报废理由'></textarea>
		   				</div>
	   				</div>
	   				
	   			</div>
	   			
	   			<div class='am-u-sm-12' style="text-align:center;margin-top:10px">
	   					<a class='am-btn am-btn-sm am-btn-primary am-radius apply_ok'>提交申请</a>
	   					<a class='am-btn am-btn-sm am-btn-primary am-radius apply_no'>取消</a>
	   			</div>
	   		</form>
   			</div>
   		`,
   		success:function(){
   			$('.car_number').on('click',function(){
				choosecar("{:url('car/index',['op'=>'search'])}")
			});
   			$('.car_detail').on('click',function(){
   				if($('.CarId').val()==""){
					Err('请选择车辆')
				}else{
					window.open("{:url('detail')}?car_id="+$('.CarId').val());  
	   			}
   			})
   			$('.apply_ok').on('click',function(){
   				Load()
   				$.ajax({
   					type:'post',
   					data:{
   						car_id:$('.CarId').val(),
   						why:$('.why').val()
   					},
   					url:url.add,
   					success:function(res){
   						Load(1)
   						console.log(res)
   						Msg('已提交申请')
   						ajaxscrap(data)
   						layer.close(auto)
   					},
   					error:function(){
   						Load(1)
   						Err('请求失败')
   					}
   				})
   				
   			})
   			$('.apply_no').on('click',function(){
   				layer.close(auto)
   			})
   		}
   		})
	}
	//删除
	function scrapclose(obj){
		var auto = layer.open({
   		type: 1,
   		title:false,
   		skin: 'layui-layer-rim', //加上边框
   		area: ['200px', '100px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
   				<div class='am-u-sm-12' style='text-align:center;margin-bottom:10px'>是否删除该报废单</div>
   				<div class='am-u-sm-12' style='text-align:center'>
   					<a class='am-btn am-btn-sm am-btn-primary am-radius close_ok'>是</a>
   					<a class='am-btn am-btn-sm am-btn-primary am-radius close_no'>否</a>
   				</div>
   			</div>
   		`,
   		success:function(){
   			
   			$('.close_ok').on('click',function(){
   				$.ajax({
   					type:'post',
   					data:{
   						car_scrap_id:obj.closest('tr').data('id')
   					},
   					url:url.delete,
   					success:function(res){
   						Load(1)
   						console.log(res)
   						Msg('删除完成')
   						ajaxscrap(data)
   						layer.close(auto)
   					},
   					error:function(){
   						Load(1)
   						Err('请求失败')
   					}
   				})
			})
			$('.close_no').on('click',function(){
				layer.close(auto)
			})
   		}
   		})
	}
	function assess(obj,main){
		var auto = layer.open({
   		type: 1,
   		title:'报废评估',
   		skin: 'layui-layer-rim', //加上边框
   		area: ['500px', '180px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
   				<div style='text-align:center'>评估<a href='{:url("detail")}?_blank=1'  target="_blank">${main.number}</a>是否可以进行报废</div>
	   			<div class='am-u-sm-12' style="text-align:center;margin-top:10px">
   					<a class='am-btn am-btn-sm am-btn-primary am-radius assess_ok'>通过</a>
   					<a class='am-btn am-btn-sm am-btn-primary am-radius assess_no'>不通过</a>
	   			</div>
		   		
   			</div>
   		`,
   		success:function(){
   			
   			$('.assess_ok').on('click',function(){
   				Load()
   				$.ajax({
   					type:'post',
   					data:{
   						car_scrap_id:obj.closest('tr').data('id'),
   						state:2
   					},
   					url:url.check,
   					success:function(res){
   						Load(1)
   						console.log(res)
   						Msg('评价通过')
   						ajaxscrap(data)
   						layer.close(auto)
   					},
   					error:function(){
   						Load(1)
   						Err('请求失败')
   					}
   				})
				
   			})
   			
   			$('.assess_no').on('click',function(){
   				Msg('评估不通过')
   				obj.closest('.operate').parent().prev().html('评估不通过')
				obj.remove()
				layer.close(auto)
   			})
   		}
   		})
	}
	function firstcheck(obj,main){
		var auto = layer.open({
   		type: 1,
   		title:'报废申请审核',
   		skin: 'layui-layer-rim', //加上边框
   		area: ['500px', '250px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
	   			<form class="am-form-inline tpl-form-border-form" enctype="multipart/form-data" data-check="1" data-ajax="1" id="scrap1">
		   			<div class='am-u-sm-12'>
		   				<div class="am-u-sm-12">
		   					<div class='am-u-sm-3' style='font-size:14px;text-align:right'>
			   					车牌号:
			   				</div>
			   				<div class='am-u-sm-9' style='font-size:14px' >
				   				<div class='am-fl' style='padding:0 10px 0 0'>
				   					${main.number}
				   				</div>
				   				<div class='am-btn-group am-fl am-btn-group-xs cl-p' >
				   					<button type="button" class='am-btn am-btn-default car_detail'>查看车辆详情</button>
				   				</div>
			   				</div>
		   				</div>
		   				<div class="am-u-sm-12">
		   					<div class='am-u-sm-3' style='font-size:14px;text-align:right'>
			   					申请人:
			   				</div>
			   				<div class='am-u-sm-9' style='font-size:14px' >${main.people}</div>
		   				</div>
		   				<div class="am-u-sm-12">
		   					<div class='am-u-sm-3' style='font-size:14px;text-align:right'>
			   					申请时间:
			   				</div>
			   				<div class='am-u-sm-9' style='font-size:14px' >
			   					${main.date}
			   				</div>
		   				</div>
		   				<div class="am-u-sm-12">
		   					<div class='am-u-sm-3' style='font-size:14px;text-align:right'>
		   						报废原因:
		   					</div>
			   				<div class='am-u-sm-9' style='font-size:14px' >
			   					${main.why}
			   				</div>
		   				</div>
		   				
		   			</div>
		   			
		   			<div class='am-u-sm-12' style="text-align:center;margin-top:10px">
	   					<a class='am-btn am-btn-sm am-btn-primary am-radius scrap_ok'>同意报废</a>
	   					<a class='am-btn am-btn-sm am-btn-primary am-radius scrap_no'>拒绝报废</a>
		   			</div>
		   		</form>
   			</div>
   		`,
   		success:function(){
   			$('.car_detail').on('click',function(){
   				choosecar("{:url('detail')}?id="+main.car_id,'车辆详情')
   			})
   			$('.scrap_ok').on('click',function(){
   				Load()
   				$.ajax({
   					type:'post',
   					data:{
   						car_scrap_id:obj.closest('tr').data('id'),
   						state:4
   					},
   					url:url.check,
   					success:function(res){
   						Load(1)
   						console.log(res)
   						Msg('审核通过')
   						ajaxscrap(data)
   						layer.close(auto)
   					},
   					error:function(){
   						Load(1)
   						Err('请求失败')
   					}
   				})
				
   			})
   		}
   		})
	}
	function notarize(obj){
		var auto = layer.open({
   		type: 1,
   		title:'报废申请确认',
   		skin: 'layui-layer-rim', //加上边框
   		area: ['350px', '250px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
   			<form class="am-form-inline tpl-form-border-form" enctype="multipart/form-data" data-check="1" data-ajax="1" id="scrap2">
	   			<div class='am-u-sm-12' style='font-size:14px'>
	   				<div class="am-u-sm-12">
		   				<div class='am-u-sm-5 cl-p' >
		   					交警部门:
		   				</div>
		   				<div class='am-u-sm-7 am-g' >
		   					<label class="am-radio">
							  <input type="radio" name="traffic" value="1"> 确认
							</label>
							<label class="am-radio">
							  <input type="radio" name="traffic" value="2" checked> 未确认
							</label>
		   				</div>
	   			
	   				</div>
	   				<div class="am-u-sm-12 ">
		   				<div class='am-u-sm-5 cl-p' >
		   					编制管理单位:
		   				</div>
		   				<div class='am-u-sm-7 am-g' >
		   					<label class="am-radio">
							  <input type="radio" name="unit" value="1" >  确认
							</label>
							<label class="am-radio">
							  <input type="radio" name="unit" value="2" checked> 未确认
							</label>
		   				</div>
	   			
	   				</div>
	   				
	   			</div>
	   			
	   			<div class='am-u-sm-12' style="text-align:center;margin-top:10px">
   					<button type="button" class='am-btn am-btn-sm am-btn-primary am-radius scrap_ok2' disabled>同意</button>
   					<button type="button" class='am-btn am-btn-sm am-btn-primary am-radius scrap_no2'>取消</button>
	   			</div>
	   		</form>
   			</div>
   		`,
   		success:function(){
   			$('input[name="traffic"]').on('change',function(){
   				if($(this).val()==1){
   					if($('input[name="unit"]:checked').val()==1){
   						$('.scrap_ok2').removeAttr('disabled')
   					}else{
   						$('.scrap_ok2').attr('disabled','disabled')
   					}
   				}else{
   						$('.scrap_ok2').attr('disabled','disabled')
   					}
   			})
   			$('input[name="unit"]').on('change',function(){
   				
   				if($(this).val()==1){
   					if($('input[name="traffic"]:checked').val()==1){
   						$('.scrap_ok2').removeAttr('disabled')
   					}else{
   						$('.scrap_ok2').attr('disabled','disabled')
   					}
   				}else{
   						$('.scrap_ok2').attr('disabled','disabled')
   					}
   			})
   			$('.scrap_no2').on('click',function(){
   				layer.close(auto)
   			})
   			$('.scrap_ok2').on('click',function(){
   				Load()
   				$.ajax({
   					type:'post',
   					data:{
   						car_scrap_id:obj.closest('tr').data('id'),
   						state:6
   					},
   					url:url.check,
   					success:function(res){
   						Load(1)
   						console.log(res)
   						Msg('已确认')
   						ajaxscrap(data)
   						layer.close(auto)
   					},
   					error:function(){
   						Load(1)
   						Err('请求失败')
   					}
   				})
   			})
   		}
   		})
	}
	
	function secondcheck(obj,main){
		var auto = layer.open({
   		type: 1,
   		title:'报废申请登记',
   		skin: 'layui-layer-rim', //加上边框
   		area: ['650px', '400px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
   			<form class="am-form-inline tpl-form-border-form" enctype="multipart/form-data" data-check="1" data-ajax="1" id="scrap2">
	   			<div class='am-u-sm-12'>
	   				<div class="am-u-sm-12" style='margin-bottom:10px'>
	   				<div class="am-u-sm-12">
		   				<div class='am-u-sm-3' style='text-align:right'>
		   					${main.number}
		   				</div>
		   				<div class='am-btn-group am-fl am-btn-group-xs cl-p' >
		   					<button type="button" class='am-btn am-btn-default car_detail'>查看车辆详情</button>
		   				</div>
	   				</div>
	   				</div>
	   				<div class="am-u-sm-12" style='margin-bottom:10px'>
	   					<div class="am-u-sm-12" style='font-size:14px'>
		   					<div class='am-u-sm-3' style='text-align:right;padding:6px 10px'>
		   						报废地点:
		   					</div>
		   					<div class='am-u-sm-4 cl-p'>
		   						<input type='text' class="scrap_add"/>
		   					</div>
		   					<div class='am-u-sm-5 cl-p'></div>
	   					</div>
	   				</div>
	   				<div class="am-u-sm-12" style='margin-bottom:10px;font-size:14px'>
	   					<div  class="am-u-sm-12">
		   					<div class='am-u-sm-3' style='text-align:right;padding:6px 10px'>
		   						报废登记人:
		   					</div>
		   					<div class='am-u-sm-4 cl-p'>
		   						<input type='text' class="scrap_check"/>
		   					</div>
		   					<div class='am-u-sm-5 cl-p' ></div>
	   					</div>
	   				</div>
	   				
	   				<div class="am-u-sm-12 ">
	   					<div class='am-u-sm-3' style='text-align:right'>
		   					上传图片:
		   				</div>	
		   				<div class='am-u-sm-9 cl-p' >
							<div class="am-form-group file-w">
								<div style="width: 150px;height: 100px;">
									<img class="fileimg" data-magnify="1" src="{if $item.driving_license_img2}{:CxImg($item.driving_license_img2)}{else/}{$static_dir}/assets/img/noimg.gif{/if}" style="width: 100%;height: 100%;" />
								</div>
								<button type="button" data-type='file' class="am-btn am-btn-danger am-btn-sm imgfileadd"><i class="am-icon-cloud-upload"></i> 添加凭证图片</button>
								<input type="file"  class='scrap_file' style="display: none;">
							</div>
						</div>	
					</div>
	   			</div>
	   			
	   			<div class='am-u-sm-12' style="text-align:center;margin-top:10px">
   					<a class='am-btn am-btn-sm am-btn-primary am-radius scrap_ok2'>登记</a>
   					<a class='am-btn am-btn-sm am-btn-primary am-radius scrap_no2'>取消</a>
	   			</div>
	   		</form>
   			</div>
   		`,
   		success:function(){
   			$('.car_detail').on('click',function(){
   				choosecar("{:url('detail')}?car_id="+$('.CarId').val(),'车辆详情')
   			})
   			$('.imgfileadd').on('click',function(){
   				$('.scrap_file').click()
   			})
   			$('.scrap_file').on('change',function(){
				var fil=$(this)[0].files[0];
				var that=this;
				var reader = new FileReader();
				reader.onload = function(evt) {
					$(that).closest('.file-w').find('.fileimg').attr('src',evt.target.result)
				}
				reader.readAsDataURL(fil);
			})
   			
   			$('.scrap_ok2').on('click',function(){
   				Load()
   				var file = $('.scrap_file')[0].files[0]; 
				var formData = new FormData();
				var name = $('.scrap_file').val();
				formData.append("image",file);
				formData.append("name",name);
   				$.ajax({
   					type:'post',
   					data:formData,
   					url:url.upload,
   					processData : false, 
					contentType : false,
   					success:function(res1){
   						console.log(res1)
// 						
		   				$.ajax({
		   					type:'post',
		   					data:{
		   						car_scrap_id:obj.closest('tr').data('id'),
		   						state:7,
		   						scrap_add:$('.scrap_add').val(),
		   						scrap_check:$('.scrap_check').val(),
		   						scrap_image:res1.image
		   					},
		   					url:url.check,
		   					success:function(res){
		   						Load(1)
		   						console.log(res)
		   						Msg('已确认')
		   						ajaxscrap(data)
		   						layer.close(auto)
		   					},
		   					error:function(){
		   						Load(1)
		   						Err('请求失败')
		   					}
		   				})
   					}
   				})
// 				
   			})
   		}
   		})
	}
	function secondnotarize(obj,main){
		console.log(main)
		var secondnita=`<div class='am-u-sm-12' style='padding:10px;font-size:14px;height:100%'>
				   			<div class='am-u-sm-12 cl-p'  style='height:100%'>
				   				<div class='am-u-sm-6 cl-p'>
					   				<div class="am-u-sm-12 cl-p">
				   						<div class='am-u-sm-4' style='text-align:right'>
					   						车牌号:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						<a href='{:url("detail")}'  target="_blank">${main.number}</a>
					   					</div>
							   				
						   			</div>
						   			
					   				<div class="am-u-sm-12 cl-p">
					   					<div class='am-u-sm-4' style='text-align:right'>
					   						报废申请人:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.people?main.people:'-'}
					   					</div>
					   					
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						申请时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.date_2?main.date_2:'-'}
					   					</div>
						   				
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						报废审核人:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.scrap_check?main.scrap_check:'-'}
					   					</div>
					   					
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						审核时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.date_4?main.date_4:'-'}
					   					</div>
						   				
						   			</div>
									<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
										   确认时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
										  ${main.date_6?main.date_6:'-'}
					   					</div>
									</div>
									<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
										   登记时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
										  ${main.date_8?main.date_8:'-'}
					   					</div>
									</div>
									<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
										   登记人:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
										   ${main.scrap_check?main.scrap_check:'-'}
					   					</div>
						   			</div>
						   			
						   			<div class="am-u-sm-12 cl-p">
					   					<div class='am-u-sm-4 ' style='text-align:right'>
					   						报废理由:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.why?main.why:'-'}
					   					</div>
						   				<div class='am-u-sm-12'>
						   					
						   				</div>
					   				</div>
					   			</div>
					   			<div class='am-u-sm-6 ' style='height:80%'>
					   				<img class='magnifyauction' src='${main.scrap_image?main.scrap_image:'-'}' alt="报废凭证" data-magnify='1' style='height:95%;width:100%;border:1px solid #999'>
					   			</div>
					   			<div class='am-u-sm-12 ' style='text-align:center'>
					   				<button class="am-btn am-btn-sm am-btn-primary am-radius secondnota_ok">审核</button>
					   				<button class="am-btn am-btn-sm am-btn-primary am-radius secondnota_no">取消</button>
					   			</div>
					   		</div>
					   	</div>`
			var nota2 = layer.open({
		   		type: 1,
		   		title:'车辆报废复审',
		   		skin: 'layui-layer-rim', //加上边框
		   		area: ['600px', '350px'], //宽高
		   		content: secondnita,
		   		success:function(){
		   			$('.secondnota_ok').on('click',function(){
		   			Load()
	   				$.ajax({
	   					type:'post',
	   					data:{
	   						car_scrap_id:obj.closest('tr').data('id'),
	   						state:8
	   					},
	   					url:url.check,
	   					success:function(res){
	   						Load(1)
	   						console.log(res)
	   						Msg('复审通过')
	   						ajaxscrap(data)
	   						layer.close(auto)
	   					},
	   					error:function(){
	   						Load(1)
	   						Err('请求失败')
	   					}
	   				})
	   				})
		   			$('.secondnota_no').on('click',function(){
		   				layer.close(nota2)
		   			})
		   		}
   			})
	}
	function detailscrap(obj,main){
		var lay_height=0;
		var lay_width=0;
		var detailmain=``;
		if(obj.data('type')==3){
			lay_height="300px";
			lay_width='330px';
			detailmain+=`<div class='am-u-sm-12' style='padding:10px;font-size:14px;height:100%'>
				   			<div class='am-u-sm-12 cl-p'  style='height:100%'>
				   				<div class='am-u-sm-12 cl-p'>
					   				<div class="am-u-sm-12 cl-p">
				   						<div class='am-u-sm-4' style='text-align:right'>
					   						车牌号:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						<a href='{:url("detail")}'  target="_blank">${main.number}</a>
					   					</div>
							   				
						   			</div>
						   			
					   				<div class="am-u-sm-12 cl-p">
					   					<div class='am-u-sm-4' style='text-align:right'>
					   						报废申请人:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.people?main.people:''}
					   					</div>
					   					
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						申请时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.date}
					   					</div>
						   				
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						报废审核人:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.scrap_check}
					   					</div>
					   					
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						审核时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   							${main.date_4}
					   					</div>
			   						</div>`
		}else if(obj.data('type')==4){
			lay_height="300px";
			lay_width='330px';
			detailmain+=`
						<div class='am-u-sm-12' style='padding:10px;font-size:14px;height:100%'>
				   			<div class='am-u-sm-12 cl-p'  style='height:100%'>
				   				<div class='am-u-sm-12 cl-p'>
					   				<div class="am-u-sm-12 cl-p">
				   						<div class='am-u-sm-4' style='text-align:right'>
					   						车牌号:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						<a href='{:url("detail")}'  target="_blank">${main.number}</a>
					   					</div>
							   				
						   			</div>
						   			
					   				<div class="am-u-sm-12 cl-p">
					   					<div class='am-u-sm-4' style='text-align:right'>
					   						报废申请人:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.number}
					   					</div>
					   					
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						申请时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.date}
					   					</div>
						   				
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						报废审核人:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.scrap_check}
					   					</div>
					   					
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						审核时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   							${main.date_4}
					   					</div>
						   				
						   			</div>
									<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
										   确认时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
										  ${main.date_6}
					   					</div>
						   			</div>`
		}else if(obj.data('type')>=5){
			lay_height="380px";
			lay_width='600px';
			detailmain+=`
						<div class='am-u-sm-12' style='padding:10px;font-size:14px;height:100%'>
				   			<div class='am-u-sm-12 cl-p'  style='height:100%'>
				   				<div class='am-u-sm-6 cl-p'>
					   				<div class="am-u-sm-12 cl-p">
				   						<div class='am-u-sm-4' style='text-align:right'>
					   						车牌号:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						<a href='{:url("detail")}'  target="_blank">${main.number}</a>
					   					</div>
							   				
						   			</div>
						   			
					   				<div class="am-u-sm-12 cl-p">
					   					<div class='am-u-sm-4' style='text-align:right'>
					   						报废申请人:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.people}
					   					</div>
					   					
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						申请时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.date}
					   					</div>
						   				
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						报废审核人:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.scrap_check}
					   					</div>
					   					
						   			</div>
						   			<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
					   						审核时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
					   						${main.date_4}
					   					</div>
						   				
						   			</div>
									<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
										   确认时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
										  ${main.date_6}
					   					</div>
									</div>
									<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
										   登记时间:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
										  ${main.date_7}
					   					</div>
									</div>
									<div class="am-u-sm-12 cl-p">
						   				<div class='am-u-sm-4' style='text-align:right'>
										   登记人:
					   					</div>
					   					<div class='am-u-sm-8 cl-p' >
										  ${main.scrap_check}
					   					</div>
						   			</div>
									`
		}
		detailmain+=`
			   			<div class="am-u-sm-12 cl-p">
		   					<div class='am-u-sm-4 ' style='text-align:right'>
		   						报废理由:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.why}
		   					</div>
			   				<div class='am-u-sm-12'>
			   					
			   				</div>
		   				</div>
		   			</div>
		   		`
		if(obj.data('type')>=5){
			detailmain+=`<div class='am-u-sm-6 ' style='height:100%'>
		   				<img class='magnifyauction' src='${main.scrap_image}' alt="报废凭证" data-magnify='1' style='height:95%;width:100%;border:1px solid #999'>
		   			</div>`
		}
		detailmain+=`</div>
   			</div>`
		console.log(lay_width)
		var auto = layer.open({
   		type: 1,
   		title:'车辆报废详情',
   		skin: 'layui-layer-rim', //加上边框
   		area: [lay_width, lay_height], //宽高
   		content: detailmain,
   		success:function(){
   			$('.car_detail').on('click',function(){
   				choosecar("{:url('detail')}?car_id="+$('.CarId').val(),'车辆详情')
   			})
   			$('.magnifyauction').on('click',function(){
				if($(this).data('magnify')){
					console.log($(this).attr('src'))
					layer.open({
					  type: 1,
					  title:false,
					  skin: 'layui-layer-rim', //加上边框
					  area: ['50%', '80%'], //宽高
					  content: `<img style="width: 100%;height:100%;" src="${$(this).attr('src')}" />`
					});
				}
			});
   		}
   		})
	}
})
